<?php

use console\services\MigrateService;
use yii\db\Migration;

/**
 * Handles the creation of table `sys_admin`.
 */
class m231229_144100_create_sys_admin_table extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->createTable('sys_admin', [
            'id' => $this->bigPrimaryKey(),
            'user_name' => $this->string(32)->defaultValue('')->notNull()->comment('登录名'),
            'nick_name' => $this->string(64)->defaultValue('')->notNull()->comment('人员姓名'),
            'user_type' => $this->string(32)->defaultValue('')->null()->comment('用户类型'),
            'password' => $this->string(128)->defaultValue('')->null()->comment('登录密码'),
            'avatar' => $this->string(255)->defaultValue('')->null()->comment('头像'),
            'email' => $this->string(64)->defaultValue('')->null()->comment('邮箱'),
            'phone' => $this->string(32)->defaultValue('')->null()->comment('电话'),
            'sex' => $this->char(1)->defaultValue('0')->null()->comment('性别'),
            'status' => $this->char(1)->defaultValue('1')->null()->comment('状态'),
            'remark' => $this->string(255)->defaultValue('')->null()->comment('备注'),
            'create_time' => $this->bigInteger()->defaultValue(0)->null()->comment('创建时间'),
            'update_time' => $this->bigInteger()->defaultValue(0)->null()->comment('更新时间'),
        ], MigrateService::createTableOptions('人员表'));

        $this->batchInsert('sys_admin',
            ['id', 'user_name', 'nick_name', 'user_type', 'password', 'status', 'remark', 'create_time', 'update_time'],
            [
                [10000, 'admin', '超管', '0', '4460ec7778e412dd94039ff0f1ed0adf', '1', '超级管理员', '1732850585', '1732850585']
            ]
        );
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('sys_admin');
    }
}
